package com.young.design.pattern.singleton;

import java.io.IOException;
import java.util.Properties;

/**
 * 饿汉式-静态代码块方式
 */
public class SingleTon3 {
    private static SingleTon3 singleTon3;

    private String info;

    static {
        Properties properties = new Properties();
        try {
            properties.load(SingleTon3.class.getClassLoader().getResourceAsStream("singleton.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        singleTon3 = new SingleTon3();
        singleTon3.setInfo(properties.getProperty("info"));
    }

    private SingleTon3(){

    }

    public static SingleTon3 getInstance(){
        return singleTon3;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }


    public static void main(String[] args) {
        SingleTon3 instance = SingleTon3.getInstance();
        System.out.println(instance.getInfo());
    }
}
